//
// Created by v on 24-5-15.
//

#ifndef JKLIBS_CONTROL_REMOTE_SERVICE_H
#define JKLIBS_CONTROL_REMOTE_SERVICE_H

#include <iostream>
#include "control_config.h"
#include "mongoose.h"

class ControlRemoteService
{
  public:
    ControlRemoteService();
    virtual ~ControlRemoteService();

    int start(const char *addr, int port);
    int stop();

    int sendData(std::string &data);

    int doCycle();

  protected:
    friend void mg_ws_connect_handler(struct mg_connection *conn, int ev, void *ev_data);


  private:
    int connPort = 0;
    std::string connAddr;
    struct mg_connection *conn;
    struct mg_mgr  mgr;
};

#endif // JKLIBS_CONTROL_REMOTE_SERVICE_H
